{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from pandas import Series, DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from datetime import datetime\n",
    "t1 = datetime(2009,10,20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2009, 10, 20, 0, 0)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "date_list = [\n",
    "    datetime(2016,9,1),\n",
    "    datetime(2016,9,10),\n",
    "    datetime(2017,9,1),\n",
    "    datetime(2017,9,20),\n",
    "    datetime(2017,10,1)\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[datetime.datetime(2016, 9, 1, 0, 0),\n",
       " datetime.datetime(2016, 9, 10, 0, 0),\n",
       " datetime.datetime(2017, 9, 1, 0, 0),\n",
       " datetime.datetime(2017, 9, 20, 0, 0),\n",
       " datetime.datetime(2017, 10, 1, 0, 0)]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = Series(np.random.rand(5), index=date_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2016-09-01    0.428998\n",
       "2016-09-10    0.156294\n",
       "2017-09-01    0.508415\n",
       "2017-09-20    0.858535\n",
       "2017-10-01    0.489239\n",
       "dtype: float64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.42899819,  0.15629389,  0.50841498,  0.85853468,  0.4892385 ])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2016-09-01', '2016-09-10', '2017-09-01', '2017-09-20',\n",
       "               '2017-10-01'],\n",
       "              dtype='datetime64[ns]', freq=None)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.15629389030101237"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.15629389030101237"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1[datetime(2016,9,10)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.15629389030101237"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1['2016-9-10']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.15629389030101237"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1['20160910']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2017-09-01    0.508415\n",
       "2017-09-20    0.858535\n",
       "dtype: float64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1['2017-09']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2016-09-01    0.428998\n",
       "2016-09-10    0.156294\n",
       "dtype: float64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1['2016']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2017-09-01    0.508415\n",
       "2017-09-20    0.858535\n",
       "2017-10-01    0.489239\n",
       "dtype: float64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1['2017']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2016-09-01    0.428998\n",
       "2016-09-10    0.156294\n",
       "2017-09-01    0.508415\n",
       "2017-09-20    0.858535\n",
       "2017-10-01    0.489239\n",
       "dtype: float64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "date_list_new = pd.date_range('2016-01-01', periods=100, freq='5H')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "s2 = Series(np.random.rand(100), index=date_list_new)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2016-01-01 00:00:00    0.605104\n",
       "2016-01-01 05:00:00    0.304700\n",
       "2016-01-01 10:00:00    0.616630\n",
       "2016-01-01 15:00:00    0.000129\n",
       "2016-01-01 20:00:00    0.452539\n",
       "2016-01-02 01:00:00    0.391670\n",
       "2016-01-02 06:00:00    0.052098\n",
       "2016-01-02 11:00:00    0.147992\n",
       "2016-01-02 16:00:00    0.479844\n",
       "2016-01-02 21:00:00    0.655001\n",
       "2016-01-03 02:00:00    0.131023\n",
       "2016-01-03 07:00:00    0.911695\n",
       "2016-01-03 12:00:00    0.317450\n",
       "2016-01-03 17:00:00    0.734720\n",
       "2016-01-03 22:00:00    0.341769\n",
       "2016-01-04 03:00:00    0.798591\n",
       "2016-01-04 08:00:00    0.686650\n",
       "2016-01-04 13:00:00    0.664793\n",
       "2016-01-04 18:00:00    0.750139\n",
       "2016-01-04 23:00:00    0.629897\n",
       "2016-01-05 04:00:00    0.817218\n",
       "2016-01-05 09:00:00    0.168748\n",
       "2016-01-05 14:00:00    0.777490\n",
       "2016-01-05 19:00:00    0.312271\n",
       "2016-01-06 00:00:00    0.917229\n",
       "2016-01-06 05:00:00    0.216342\n",
       "2016-01-06 10:00:00    0.955800\n",
       "2016-01-06 15:00:00    0.299533\n",
       "2016-01-06 20:00:00    0.911665\n",
       "2016-01-07 01:00:00    0.945937\n",
       "                         ...   \n",
       "2016-01-15 14:00:00    0.957775\n",
       "2016-01-15 19:00:00    0.379725\n",
       "2016-01-16 00:00:00    0.524612\n",
       "2016-01-16 05:00:00    0.845913\n",
       "2016-01-16 10:00:00    0.962449\n",
       "2016-01-16 15:00:00    0.050495\n",
       "2016-01-16 20:00:00    0.891761\n",
       "2016-01-17 01:00:00    0.859840\n",
       "2016-01-17 06:00:00    0.214825\n",
       "2016-01-17 11:00:00    0.048916\n",
       "2016-01-17 16:00:00    0.874778\n",
       "2016-01-17 21:00:00    0.911794\n",
       "2016-01-18 02:00:00    0.024814\n",
       "2016-01-18 07:00:00    0.400845\n",
       "2016-01-18 12:00:00    0.597310\n",
       "2016-01-18 17:00:00    0.128828\n",
       "2016-01-18 22:00:00    0.695867\n",
       "2016-01-19 03:00:00    0.421547\n",
       "2016-01-19 08:00:00    0.444459\n",
       "2016-01-19 13:00:00    0.118375\n",
       "2016-01-19 18:00:00    0.986126\n",
       "2016-01-19 23:00:00    0.557295\n",
       "2016-01-20 04:00:00    0.889288\n",
       "2016-01-20 09:00:00    0.562900\n",
       "2016-01-20 14:00:00    0.932922\n",
       "2016-01-20 19:00:00    0.748682\n",
       "2016-01-21 00:00:00    0.206834\n",
       "2016-01-21 05:00:00    0.876719\n",
       "2016-01-21 10:00:00    0.119583\n",
       "2016-01-21 15:00:00    0.665986\n",
       "Freq: 5H, Length: 100, dtype: float64"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
